package com.by.service.impl;


import cn.hutool.system.UserInfo;
import com.by.bean.SupplierInquiry;
import com.by.common.bean.PageBean;
import com.by.common.crud.BaseServiceImpl;
import com.by.common.ex.BusinessException;
import com.by.common.utils.Assert;
import com.by.mapper.SupplierInquiryDetailMapper;
import com.by.mapper.SupplierInquiryMapper;
import com.by.query.SupplierInquiryQuery;
import com.by.query.SupplierQuery;
import com.by.service.SupplierInquiryService;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class SupplierInquiryServiceImpl extends BaseServiceImpl<SupplierInquiry, SupplierInquiryMapper> implements SupplierInquiryService {

    @Autowired
    SupplierInquiryDetailMapper supplierInquiryDetailMapper;

    @Autowired
    SupplierInquiryMapper supplierInquiryMapper;

    @Override
    public int save(SupplierInquiry entity) {
        //产生编码 CPXJ20250301
        entity.setSn("CPXJ20250301");
        //获取当前操作人 信息
       // UserInfo info = UserContext.get();
//        entity.setSeller_id(info.getId());

        return super.save(entity);
    }

    @Override
    public PageBean query(SupplierInquiryQuery supplierInquiryQuery) {
        //分页查询
        PageHelper.startPage(supplierInquiryQuery.getPage(), supplierInquiryQuery.getPageSize());//后面紧跟查询
        List list = baseMapper.query(supplierInquiryQuery);
        System.out.println(list);
        PageInfo info = new PageInfo(list);
        return new PageBean(supplierInquiryQuery.getPage(), supplierInquiryQuery.getPageSize(), info.getTotal(), list);
    }
}
